package hillfly.wifichat.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;

import hillfly.wifichat.R;
import hillfly.wifichat.common.BaseActivity;

/**
 * Created by Administrator on 2017/7/18.
 */

public class StartActivity extends BaseActivity implements View.OnClickListener {
    Button middleBt;
    Button rightBt;
    Dialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        initViews();
        initEvents();
    }

    @Override
    protected void initViews() {
        middleBt = (Button)findViewById(R.id.middle);
        rightBt = (Button)findViewById(R.id.right);
    }

    @Override
    protected void initEvents() {
        middleBt.setOnClickListener(this);
        rightBt.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.middle){
            showDialog();
        }else if(v.getId() == R.id.right){
            startActivity(TrafficstatsActivity.class);
        }
    }

    private void showDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("列表对话框");
//        builder.setIcon(R.drawable.dialog);
        DialogInterface.OnClickListener listener =
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface,
                                        int which) {
//                        EditText editText =
//                                (EditText) findViewById(R.id.editText);
//                        editText.setText("你选择了: " +getResources()
//                                .getStringArray(R.array.hobby)[which]);
                    }
                };
        builder.setItems(R.array.name_array, listener);
        dialog = builder.create();
        dialog.show();
    }

//    @Override
//    public Dialog onCreateDialog(Bundle savedInstanceState) {
//        AlertDialog.Builder builder = new AlertDialog.Builder(StartActivity.this);
//        builder.setTitle("UserName")
//                .setItems(R.array.name_array, new DialogInterface.OnClickListener() {
//                    public void onClick(DialogInterface dialog, int which) {
//                        // The 'which' argument contains the index position
//                        // of the selected item
//                    }
//                });
//        return builder.create();
//    }
}
